<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
<!--                            <li>-->
<!--                                <label>密码：</label>-->
<!--                                <input type="text" name="passwd"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>更新时间：</label>-->
<!--                                <input type="text" class="time-input" placeholder="请选择更新时间" name="endUpdate"/>-->
<!--                            </li>-->
                            <li>
                                <label>姓名：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>账号：</label>
                                <input type="text" name="acc"/>
                            </li>
                            <li>
                                <label>当天学习状态：</label>
                                <input type="text" name="stateDay"/>
                            </li>
                            <li>
                                <label>已完成学时：</label>
                                <input type="text" name="classHour"/>
                            </li>
                            <li>
                                <label>账号状态：</label>
                                <input type="text" name="state"/>
                            </li>
                            <li>
                                <label>备注：</label>
                                <input type="text" name="ramarks"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:list:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary multiple disabled" onclick="$.operate.edit()" shiro:hasPermission="system:list:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:list:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:list:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:list:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:list:remove')}]];
        var prefix = ctx + "system/list";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "【请填写功能名称】",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'acc',
                    title: '账号',
                    // visible: false
                },
                {
                    field: 'type',
                    title: '类型',
                    // visible: false
                },
                {
                    field: 'passwd',
                    title: '密码'
                },
                {
                    field: 'endUpdate',
                    title: '更新时间',
                    sortable: true
                },
                {
                    field: 'stateDay',
                    title: '当天学习状态',
                    sortable: true
                },
                {
                    field: 'classHour',
                    title: '已完成学时',
                    sortable: true
                },
                {
                    field: 'state',
                    title: '账号状态',
                    sortable: true
                },
                {
                    field: 'ramarks',
                    title: '备注',
                    sortable: true
                },
                    {
                        field: 'name',
                        title: '姓名',
                        sortable: true
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.acc + '\',\'' + row.type + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="Delete(\'' + row.acc + '\',\'' + row.type + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function Delete(acc,type){
            $.ajax({
                type:"Post",
                url:"/system/list/remove",
                data:{acc:acc,type:type},
                dataType:"json",
                success:function (data){
                    $.form.reset()
                },
                error:function (error){
                }
            })
        }
    </script>
</body>
</html>